<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/30 0030
 * Time: 14:44
 */

namespace Route;

/**
 * @description:服务中心配置
 * @auth:yfl
 * @email:554665488@qq.com
 * Class Config
 * @package Route
 */
class Config
{
    static $map = [];
    const CONFIG_DIR = __DIR__ . '/Config/*.php';

    public static function loadConfig()
    {
        $configFiles = glob(self::CONFIG_DIR);
        if (!empty($configFiles)) {
            foreach ($configFiles as $configFile) {
                self::$map += include "$configFile";
            }
        }
    }

    public static function get($configKey = '')
    {
        self::loadConfig();
        if($configKey == '') return self::$map;
        if (isset(self::$map[$configKey])) {
            return self::$map[$configKey];
        } else {
            throw  new \Exception('获取配置失败');
        }
    }
}